package com.wjk.service.impl;

import com.wjk.mapper.PermissionMapper;
import com.wjk.pojo.Permission;
import com.wjk.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: RobertWei
 * time: 2021/8/15    15:45
 * @TODO:
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    /**
     * 查询用户对应的权限名
     *
     * @param uid
     * @return
     */
    @Override
    public List<String> queryPermissionStr(int uid) {
        List<Permission> permissions = permissionMapper.queryByuId(uid);

        List<String> permissionStr = new ArrayList<>();

        for (Permission permission : permissions) {
            permissionStr.add(permission.getpName());
        }


        return permissionStr;
    }
}
